# 第四阶段，将pkl数据存储到表格或数据库中
import pickle
import pandas as pd
# import sqlalchemy
with open('step3ed.pkl','rb')as f:
    data=pd.DataFrame(pickle.load(f))
data.to_csv("data.csv",index=None)
data.to_excel("data.xlsx",index=None)
# engine=sqlalchemy.create_engine("mysql+pymysql://root:1212@localhost:3306/db1")
# data.to_sql('testtable',engine)

import sqlite3
with sqlite3.connect('D-Spider.db') as conn:
    data.to_sql('test_table', conn, if_exists='replace', index=False)